package com.applancer.notification;

import android.content.SharedPreferences;
import android.util.Log;

public class GetRegistrationId {

	

	public GetRegistrationId() {
		
		final SharedPreferences prefs = GcmData.getGCMPreferences(GcmData.act);
		String registrationId = prefs.getString(GcmData.PROPERTY_REG_ID, "");
		if (registrationId.isEmpty()) {
			Log.i(GcmData.TAG, "Registration not found.");
			GcmData.regid = null;
		}
		else Log.i("RegID",registrationId +"");
		// Check if app was updated; if so, it must clear the registration ID
		// since the existing regID is not guaranteed to work with the new
		// app version.
		int registeredVersion = prefs.getInt(GcmData.PROPERTY_APP_VERSION,
				Integer.MIN_VALUE);
		int currentVersion = GcmData.getAppVersion(GcmData.act);
		if (registeredVersion != currentVersion) {
			Log.i(GcmData.TAG, "App version changed.");
			GcmData.regid = null;
		}
	}

	public String Id() {

		return GcmData.regid;
	}

	/**
	 * @return Application's {@code SharedPreferences}.
	 */
	

}
